
package com.lsy.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.lsy.entity.Student;
import com.lsy.mapper.StudentMapper;

/**
 * Created by miaorf on 2016/6/19.
 */
@Controller
public class HelloController {

	@Autowired
	private StudentMapper stuMapper;

	@RequestMapping("/index")
	public String index(Model model) {

		model.addAttribute("name", "Ryan");

		return "index";
	}

	@RequestMapping("/json")
	@ResponseBody
	public Map<String, Object> json() {
		final Map<String, Object> map = new HashMap<String, Object>();
		map.put("name", "Ryan");
		map.put("age", "18");
		map.put("sex", "man");
		return map;
	}

	@RequestMapping("/likeName")
	public List<Student> likeName(@RequestParam String name) {
		final int i = 1;
		PageHelper.startPage(1, 1);
		return stuMapper.likeName(name);
	}

}